package com.cxy.usercenter.rocketmq;

import com.cxy.usercenter.dao.bonusEventLog.BonusEventLogMapper;
import com.cxy.usercenter.dao.user.UserMapper;
import com.cxy.usercenter.domain.dto.messaging.UserAddBonusMsgDTO;
import com.cxy.usercenter.domain.entity.bonusEventLog.BonusEventLog;
import com.cxy.usercenter.domain.entity.user.User;
import com.cxy.usercenter.service.user.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author: huayushu luming
 * @date: 2020-12-01 12:57
 * @desc:
 **/
@Service
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AddBonusStreamConsumer {

    private final UserService userService;

    @StreamListener(Sink.INPUT)
    public void receive(UserAddBonusMsgDTO message) {
        message.setEvent("CONTRIBUTE");
        message.setDescription("投稿加积分..");
        this.userService.addBonus(message);
    }

}
